package com.idea.tianmimi;

import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.TextView;

public abstract class DefalutTitleActivity extends BaseActivity {

	private FrameLayout mInfoLayout;

	private Button mLButton;

	private Button mRButton;

	private TextView mTitleView;

	@Override
	protected void preContentView() {

		setContentView(R.layout.defalut_title_page);

		mTitleView = (TextView) findViewById(android.R.id.title);

		mLButton = (Button) findViewById(android.R.id.button1);

		mRButton = (Button) findViewById(android.R.id.button2);

		mInfoLayout = (FrameLayout) findViewById(R.id.deft_title_info);

		mInfoLayout.addView(preInfoView());
	}

	protected abstract View preInfoView();

	@Override
	protected abstract void initView();

	@Override
	protected abstract void initDate();

	@Override
	public View findViewById(int id) {

		if (mInfoLayout == null) {
			return super.findViewById(id);
		} else {

			return mInfoLayout.findViewById(id);
		}
	}

	protected void setLeftButton(int resID, String text, OnClickListener l) {

		if (mLButton != null) {
			mLButton.setVisibility(View.VISIBLE);

			if (resID != 0) {
				mLButton.setBackgroundResource(resID);
			}

			mLButton.setText(text);

			if (l != null) {
				mLButton.setOnClickListener(l);
			}
		}
	}

	protected void setRightButton(int resID, String text, OnClickListener l) {

		if (mRButton != null) {

			mRButton.setVisibility(View.VISIBLE);

			if (resID != 0) {
				mRButton.setBackgroundResource(resID);
			}

			mRButton.setText(text);

			if (l != null) {
				mRButton.setOnClickListener(l);
			}
		}
	}

	protected void setTitle(String title) {

		if (mTitleView != null) {
			mTitleView.setVisibility(View.VISIBLE);

			mTitleView.setText(title);
		}
	}
	
	protected Button getLBotton()
	{
		return mLButton;
	}
	protected Button getRBotton()
	{
		return mRButton;
	}

}
